package com.walk.zworld.mvvm.vm

import androidx.lifecycle.LiveData
import com.walk.zworld.mvvm.repository.SystemRepository
import com.base.lib.base.mvvm.viewmodel.BaseRefreshViewModel
import com.base.lib.httpUtils.Article

class KnowListViewModel : BaseRefreshViewModel<Article>() {

    private val repository = SystemRepository()

    fun getKnowledgeList(cid: Int): LiveData<List<Article>> {
        launchUI {
            val result = repository.getKnowledgeList(page, cid)
            mData.value = result.data.datas
        }
        return mData
    }

    override fun refreshData(params: Any?) {
        page = 0;
        when (params) {
            is Int -> getKnowledgeList(params);
        }
    }

    override fun loadMore(params: Any?) {
        page += 1;
        when (params) {
            is Int -> getKnowledgeList(params);
        }
    }
}